package ooad.nextgen.gof.strategy;

import ooad.nextgen.domain.Money;
import ooad.nextgen.domain.Sale;

/**
 * 满减打折策略
 * 如满1000直减200，即threshold=1000，discount=200;
 *
 */
public class AbsoluteDiscountOverThresholdPricingStrategy implements ISalePricingStrategy{
	private Money threshold; //满额
	private Money discount; //折扣额
	public AbsoluteDiscountOverThresholdPricingStrategy() {
		super();
		this.threshold=new Money(1000);
		this.discount=new Money(200);
	}
	public AbsoluteDiscountOverThresholdPricingStrategy(Money discount, Money threshold) {
		super();
		this.discount = discount;
		this.threshold = threshold;
	}

	@Override
	public Money getTotal(Sale sale) {
		Money pdt = sale.getPreDiscountTotal();
		if(pdt.less(threshold))
			return pdt;
		else
			return pdt.minus(discount);
	}

}
